<script setup lang="ts">
import router from '@/router'

const onClickLeft = () => {
  // TODO 点击左侧返回按钮
  console.log('左边点击')
  console.log(history.state)
  if (history.state.back) {
    router.back()
  } else {
    router.push('/')
  }
}
const onClickRight = () => {
  // TODO 点击右侧文字按钮
  console.log('点击右侧, 触发子传父, 到底需要什么功能, 由父组件决定')
  emit('rightClick')
}

defineProps<{
  title?: string
  rightText?: string
}>()

const emit = defineEmits<{
  (e: 'rightClick'): void
}>()
</script>

<template>
  <van-nav-bar
    fixed
    left-arrow
    :title="title"
    :right-text="rightText"
    @click-left="onClickLeft"
    @click-right="onClickRight"
  ></van-nav-bar>
</template>

<style lang="scss" scoped>
:deep() {
  .van-nav-bar {
    &__arrow {
      font-size: 18px;
      color: var(--cp-text1);
    }
    &__text {
      font-size: 15px;
    }
  }
}
</style>
